package erwiki.ui.app.parts;

import org.eclipse.emf.common.notify.AdapterFactory;
import org.eclipse.emf.edit.provider.ComposedAdapterFactory;
import org.eclipse.jface.viewers.TreeViewer;
import org.eclipse.swt.SWT;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
/*:FVK: -- коллизия E3 vs E4.
import org.eclipse.emf.edit.ui.provider.AdapterFactoryContentProvider;
import org.eclipse.emf.edit.ui.provider.AdapterFactoryLabelProvider;
 */
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Tree;
import org.eclipse.swt.widgets.TreeItem;

import jakarta.annotation.PostConstruct;
import jakarta.inject.Inject;

public class TestView {
	
	public static final String ID = "erwiki.ui.part.testView"; //$NON-NLS-1$

	private ComposedAdapterFactory composedAdapterFactory;

	// == CODE ================================================================

	@Inject
	public TestView() {
		
	}
	
	/**
	 * Create contents of the view part.
	 * 
	 * @param parent
	 */
	@PostConstruct
	public void postConstruct(Composite parent) {
		parent.setLayout(new GridLayout(1, false));
		
		Tree tree = new Tree(parent, SWT.BORDER);
		tree.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1));
		
		TreeItem trtmNewTreeitem = new TreeItem(tree, SWT.NONE);
		trtmNewTreeitem.setText("New TreeItem");

		//:FVK: -- old code
		//PagesStore pages = AppUiActivator.getDefault().getAppSession().getStorageCdo().getPagesStore();

		// --------------------------------------------------------------------
		
		// initializeTreeviewerProviders(this.treeViewer);

		// --------------------------------------------------------------------

		/*:FVK: -- old code
		createActions();
		initializeToolBar();
		initializeMenu();*/
	}
	

	private void initializeTreeviewerProviders(final TreeViewer treeViewer1) {
	/*:FVK: -- коллизия E3 vs E4.
		AdapterFactoryLabelProvider labelProvider;
		AdapterFactoryContentProvider contentProvider;
		labelProvider = new AdapterFactoryLabelProvider(getAdapterFactory());
		contentProvider = new AdapterFactoryContentProvider(getAdapterFactory());
	 */
	}

	/**
	 * Return an ComposedAdapterFactory for all registered modesl
	 * 
	 * @return a ComposedAdapterFactory
	 */
	protected AdapterFactory getAdapterFactory() {
		if (this.composedAdapterFactory == null) {
			this.composedAdapterFactory = new ComposedAdapterFactory(
					ComposedAdapterFactory.Descriptor.Registry.INSTANCE);
			/* :FVK:
			this.resourcesAF = new ResourceItemProviderAdapterFactory();
			this.composedAdapterFactory.addAdapterFactory(this.resourcesAF);
			this.personsAF = new PersonsItemProviderAdapterFactory();
			this.composedAdapterFactory.addAdapterFactory(this.personsAF);
			this.reflectiveAF = new ReflectiveItemProviderAdapterFactory();
			this.composedAdapterFactory.addAdapterFactory(this.reflectiveAF);
			*/
		}
		return this.composedAdapterFactory;
	}
	
}
